<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <form>
        <label for="">学号：</label><input type="text"class="stu_id">
        <label for="">姓名：</label><input type="text" class="stu_name">
        <label for="">性别：</label><input type="text" class="stu_sex">
        <label for="">出生日期：</label><input type="text" class="stu_date">
        <label for="">爱好：</label><input type="text" class="stu_hobby">
        <label for="">男女朋友：</label><input type="text" class="stu_bgf">
        <label for="">头像：</label><input type="text" class="stu_head_img">
    </form>
    <button class="stu_info">提交学生信息</button>

    <script src="./jquery/jquery-1.12.4.min.js"></script>

    <script>
        $('.stu_info').on('click',(e)=>{
            e.preventDefault();
            $.ajax({
                method:"post",
                url:"http://localhost:3030/students_info",
                data:{
                    stu_id:$('.stu_id').val(),
                    stu_name:$('.stu_name').val(),
                    stu_sex:$('.stu_sex').val(),
                    stu_date:$('.stu_date').val(),
                    stu_gbf:$('.stu_gbf').val(),
                    stu_hobby: $('.stu_hobby').val(),
                    stu_head_img:$('.stu_head_img').val()
                },
                success:(data)=>{
                    console.log(data);
                },
                error:(err)=>{
                    console.log(err);
                }
            })
        })
    </script>
</body>
</html>